package com.hspedu.newData.dmsxl.树.二叉树的遍历.递归;

import com.hspedu.newData.dmsxl.ds.TreeNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-29 
 * @Version: 1.0
 */

public class LC100相同的树 {

    public boolean isSameTree(TreeNode p, TreeNode q) {

        if (p == null && q == null){
            return true;
        } else if (p == null || q == null) {
            return false;
        }  else {
            if (p.val != q.val){
                return false;
            }
            boolean sameTree = isSameTree(p.left, q.left);
            boolean sameTree1 = isSameTree(p.right, q.right);

            return sameTree && sameTree1;
        }
    }
}
